<template>
	<div class="conbox">
		<div class="assset_top">
			<p>可提现金额</p>
			<p>{{asset_count.seller_money}}</p>
			<p>不可用金额：{{frozen_money}}</p>
		</div>
		<ul class="assset_money">
			<li @click="skippaymodule('InviteAward')">去赚钱</li>
			<li @click="skippaymodule('PayBalance',seller_money)">提现</li>
		</ul>
		<div class="list_content">
			<ul>
				<li @click="skipcash('/pages/material/recharge/frozenCash',frozen_money)">
					<span>冻结资金账户</span>
					<span>￥{{frozen_money}}</span>
				</li>
				<li @click="skipcash('/pages/material/recharge/applyRecord')">
					<span>申请记录</span>
				</li>
				<div class="lab_line"></div>
				<li @click="skipcash('/pages/material/recharge/accountDetail')">
					<span>账户明细</span>
				</li>
				<li  @click="skipcash('/pages/material/recharge/caseDetail')">
					<span>资金明细</span>
				</li>
			</ul>
		</div>
	</div>
</template>

<script>
import { getwallet } from '@/api/payment'
export default {
	name: 'materialAsset',
	data() {
		return {
			owner_user_id: '',
			asset_count: '',
			is_real: '',
			total_income: 0,
			total_pay: 0,
			seller_money: 0,
			frozen_money: 0
		}
	},
	onLoad(opcation) {
		this.owner_user_id = opcation.owner_user_id
		this.getasset()
		uni.showLoading({
			title: '数据加载中'
		})
	},
	mounted() {

	},
	methods: {
		getasset() {
			let data = {
				ru_id: this.owner_user_id
			}
			getwallet(data).then(res => {
				if (res.status == 'success') {
					this.asset_count = res.data
					this.frozen_money = res.data.frozen_money
					this.is_real = res.data.is_real
					this.total_income = res.data.total_income.toFixed(2)
					this.total_pay = res.data.total_pay.toFixed(2)
					this.seller_money = (res.data.seller_money * 1).toFixed(2)
				} else {
					this.msg(res.message)
					this.hideloading()
				}
			})
			this.hideloading()
		},
		msg(msg) {
			uni.showToast({
				title: msg,
				icon: 'none'
			})
		},
		hideloading() {
			setTimeout(function() {
				uni.hideLoading()
			}, 500)
		},
		skiprecord() {
			uni.navigateTo({ // 申请记录
				url: `/pages/material/recharge/applyRecord?owner_user_id=${this.owner_user_id}`
			})
		},
		skippaymodule(typename, typemoney) {
			if (typename == 'InviteAward') {
				uni.navigateTo({ // 去赚钱
					url: `/pages/getGuest/inviteShop?owner_user_id=${this.owner_user_id}`
				})
			} else if (typename == 'PayBalance') {
				if (this.is_real == -1 || this.is_real == 0 || this.is_real == 2) {
					let query = {
						owner_user_id: this.owner_user_id,
						real_id: this.is_real
					}
					uni.navigateTo({
						url: `/pages/balance/userAuthentication${this.commonJS.queryData(query)}`
					})
				} else {
					let query = {
						owner_user_id: this.owner_user_id,
						real_id: this.is_real,
						cash: this.seller_money
					}
					uni.navigateTo({
						url: `/pages/balance/cashWithdrawal${this.commonJS.queryData(query)}`
					})
				}
			}
		},
		skipcash(url, money) {
			let query = {}
			query.owner_user_id = this.owner_user_id
			if (money) {
				query.cash = money
			}
			uni.navigateTo({
				url: `${url}${this.commonJS.queryData(query)}`
			})
		}
	}
}
</script>

<style scoped lang="scss">
	.conbox{
		width: 100%;
		height: 100%;
		display: block;
		background: #F5F5F5;
	}
	.assset_top{
		width: 100%;
		height: 268px;
		position: relative;
		background-image: url($imgUrl+'getguest/icon_assbg.png');
		background-size: cover;
	}
	.assset_top p{
		text-align: center;
		float: left;
		width: 100%;
		font-size: 24px;
		color: #3A1B04;
	}
	.assset_top p:first-child{
		font-size: 24px;
		margin-top: 48px;
		margin-bottom: 10px;
	}
	.assset_top p:nth-child(2){
		font-size:60px;
		font-weight: bold;
	}
	.assset_top p:nth-child(3){
		color:#A88809;
		margin-top: 12px;
	}
	.assset_money{
		width: 90%;
		height: 90px;
		left: 5%;
		top: 218px;
		position: absolute;
		border-radius: 10px;
		background: white;
	}
	.assset_money li{
		width: 50%;
		float: left;
		font-size:28px;
		line-height: 90px;
		text-align: center;
	}
	.assset_money li:first-child{
		background: url($imgUrl+'getguest/icon_makemoney.png');
		background-repeat:no-repeat;
		background-size: 40px 40px;
		background-position: 28% 24px;
	}
	.assset_money li:nth-child(2){
		background: url($imgUrl+'getguest/icon_cash.png');
		background-repeat:no-repeat;
		background-size: 40px 40px;
		background-position: 28% 24px;
	}
	.list_content{
		width: 100%;
		height: auto;
		margin-top: 70px;
	}
	.list_content ul{
		width: 100%;
		height: auto;
		background: white;
	}
	.list_content ul li{
		width: 92%;
		margin-left: 4%;
		height: 100px;
		line-height: 100px;
		font-size:24px;
		color: #666666;
		background: url($imgUrl+'login/right.png') right center;
		background-repeat:no-repeat;
		background-size: 15px 28px;
		border-bottom: 1px solid #eeeeee;
	}
	.list_content ul li:last-child{
		border-bottom: 0;
	}
	.list_content ul li span:first-child{
		float: left;
	}
	.list_content ul li span:nth-child(2){
		float: right;
		margin-right: 60px;
	}
	.lab_line{
		height: 20px;
		width: 100%;
		background: #eeeeee;
	}
</style>
